/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/container
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AETStringChar.h
// Author:		Gianluca Belardelli
// Date:		17/12/2013
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AETSTRINGCHAR_H_
#define _AETSTRINGCHAR_H_

template<>
class AETString<char>
{
// Members
protected:
	char		*m_lpString;
	const char	*m_lpStringPtr;
	AEUINT32	m_uiCapacity;
	AEUINT32	m_uiLen;

// Methods
private:
	AE_FORCEINLINE void _resetPtr( void );

public:
	AE_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( TOBEDEFINED, AETString<char> );

	///////////////////////////////////////////////////////////////
	/// @name Costruttori e distruttore
	/// @{
	///////////////////////////////////////////////////////////////
	AE_FORCEINLINE AETString( void );
	AE_FORCEINLINE AETString( const char *lpStr );
	AE_FORCEINLINE AETString( AETString<wchar_t> );
	AE_FORCEINLINE AETString( AEUINT32 uiCapacity );
	AE_FORCEINLINE AETString( AETString &copy );
	AE_FORCEINLINE ~AETString( void );

	///////////////////////////////////////////////////////////////
	/// @}
	/// @name Modifica
	/// @{
	///////////////////////////////////////////////////////////////

	AE_FORCEINLINE AETString &ToUpper( void );
	AE_FORCEINLINE AETString &ToLower( void );
	AE_FORCEINLINE char *ToChar( void );

	AE_FORCEINLINE AETString &Trim( AEINT8 cTrimChar = 32 );
	AE_FORCEINLINE AETString &LTrim( AEINT8 cTrimChar = 32 );
	AE_FORCEINLINE AETString &RTrim( AEINT8 cTrimChar = 32 );

	AE_FORCEINLINE void Clear( void );

	AE_FORCEINLINE AEUINT32 GetLength( void ) const;
	AE_FORCEINLINE bool IsEmpty( void ) const;
	AE_FORCEINLINE void SetCapacity( AEUINT32 uiCapacity );

	///////////////////////////////////////////////////////////////
	/// @}
	/// @name Accesso
	/// @{
	///////////////////////////////////////////////////////////////

	AE_FORCEINLINE AEINT32 LastIndexOf( AETString &refStr, AEUINT32 uiFromIdx = 0 ) const;
	AE_FORCEINLINE AEINT32 LastIndexOf( char *lpStr, AEUINT32 uiFromIdx = 0 ) const;
	AE_FORCEINLINE AEINT32 LastIndexOf( char cCharacter, AEUINT32 uiFromIdx = 0 ) const;

	AE_FORCEINLINE AEINT32 IndexOf( AETString &refStr, AEUINT32 uiFromIdx = 0 ) const;
	AE_FORCEINLINE AEINT32 IndexOf( char *lpStr, AEUINT32 uiFromIdx = 0 ) const;
	AE_FORCEINLINE AEINT32 IndexOf( char cCharacter, AEUINT32 uiFromIdx = 0 ) const;

	AE_FORCEINLINE AETString SubString( AEUINT32 uiStart, AEUINT32 uiNumOfChar = -1 );
	
	AE_FORCEINLINE AETString &Replace( AETString &refOldStr, AETString &refNewStr );
	AE_FORCEINLINE AETString &Replace( char *lpOldStr, char *lpNewStr );
	AE_FORCEINLINE AETString &Replace( char cOldCharacter, char cNewCharacter );

	/// Rimuove uiNumOfChars caratteri all'inizio della stringa.
	void ChompStart( AEUINT32 uiNumOfChars );
	/// Rimuove uiNumOfChars caratteri alla fine della stringa.
	void ChompEnd( AEUINT32 uiNumOfChars );
	/// Imposta la stringa come una substring di se stessa.
	void Slice( AEUINT32 uiStartOffset, AEUINT32 uiLength );

	///////////////////////////////////////////////////////////////
	/// @}
	/// @name Operatori
	/// @{
	///////////////////////////////////////////////////////////////
	AE_FORCEINLINE AETString &operator=( const char *lpStr );
	AE_FORCEINLINE AETString &operator=( const AETString &refStr );
	AE_FORCEINLINE AETString &operator=( const AETString<wchar_t> &refStr );

	AE_FORCEINLINE AETString &operator+=( const char *lpStr );
	AE_FORCEINLINE AETString &operator+=( const AETString &refStr );

	AE_FORCEINLINE char &operator[] ( AEUINT32 uiIndex );
	AE_FORCEINLINE const char &operator[] ( AEUINT32 uiIndex ) const;

};

#include "AETStringChar.inl"

#endif // _AETSTRINGCHAR_H_
